package com.zhiyou.books.controller;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zhiyou.books.pojo.Book;
import com.zhiyou.books.service.BookService;

import java.util.List;

@RestController
@RequestMapping(value = "/books")
public class BookController {
    @Autowired
    private BookService bookService;

    @GetMapping(value = "/search")
    public List<Book> getAllBooks(){
        System.out.println("controller===");
        return bookService.getAllBooks();
    }


    @GetMapping(value = "/getBookById/{id}")
    public List<Book> getAllBookById(@PathVariable Integer id){
        System.out.println("getBookById");
        return bookService.getBookById(id);
    }
}
